<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'fabu';
$setting=$this->plugin_setting('setting');
$return['setting'] = $setting;
if($_RQ['op']=='fabu'){
	$id=intval($_RQ['id']);
	$info=array();
	if($id){
	$info=pdo_get('jy_cmshouse_list',array('id'=>$id));	
	}
	$setting=$this->plugin_setting('setting');
	$postdata=get_postdata();
	if($postdata['title']){
		if(!$postdata['name']){
			exi('请输入联系人','error');
		}
		if(!$postdata['mobile']){
			exi('请输入联系电话','error');
		}
		if(!$postdata['address']){
			exi('请输入地址','error');
		}
		if(!$postdata['price']){
			exi('请输入价格','error');
		}
			$data=array_fields(array('status','title','type','logo','huxing','mianji','louceng','junjia','name','lat_lng','address','price','mobile','desc'),$postdata);
			$data['lat_lng']=json_encode($data['lat_lng']);
			if($postdata['hdp']){
				foreach($postdata['hdp'] as $v){
					$data['hdp'][]=array('image'=>$v);
				}
			}
			$data['hdp']=json_encode($data['hdp']);
			
			$id=intval($postdata['id']);
			$info=array();
			if($id){
				$info=pdo_get('jy_cmshouse_list',array('id'=>$id));	
			}
			if(empty($info)){
				$data['ishow']=1;
				if($setting['shenhe']==1){
					$data['status']=0;
				}else{
					$data['status']=1;
				}
				$data['uniacid']=$_SESSION['uniacid'];
				$data['uid']=$_SESSION['uid'];
				$data['createtime']=TIMESTAMP;
				pdo_insert('jy_cmshouse_list',$data);
				exi('发布成功！','','index/');
			}else{
				pdo_update('jy_cmshouse_list',$data);
				exi('修改成功！','','index/');
			}
		
  }
  $return['info']=$info;
  set_html('title','发布');
  exi($return);
}
?>